using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
using PropSys;

public class StRun : MovState
{
    private string _key;
    private float _pctSpd;

    public StRun(Action<StType> swcSt, MainCtrl mc, string key, float pctSpd) : base(swcSt, mc)
    {
        _key = key;
        _pctSpd = pctSpd;
    }

    public override void Enter()
    {
        _MC.PlayAnim("Idle");
        _MC.RegVal(PropType.SPD, PropReg.PCT, _key, delegate { return _pctSpd; });
    }

    public override void Exit()
    {
        _MC.UregVal(PropType.SPD, PropReg.PCT, _key);
    }

    public override void LogicUpd() { _MC.Move(); }

    public override void IptDir(Vector2 vec2)
    {
        _MC.GetDri(vec2);
        if (vec2.magnitude == 0) SwcSt(StType.Idle);
        else if (vec2.magnitude <= 0.8) SwcSt(StType.Walk);
    }

    public override void Blk() { SwcSt(StType.Blk); }
    public override void PfmSkill() { SwcSt(StType.Skill); }
    public override void Air() { _MC.Jump(); }
    public override void Dodge() { SwcSt(StType.Dodge); }
}
